/**
 * 
 */
package com.feib.stms.service.impl;

import java.util.Date;
import java.util.List;

import org.apache.commons.lang.NotImplementedException;

import com.feib.stms.dao.TempPaymentDao;
import com.feib.stms.model.BaseTempPayment;
import com.feib.stms.model.TempUploadFile;
import com.feib.stms.pagination.PaginatedList;
import com.feib.stms.service.TempPaymentService;
import com.feib.stms.util.UserUtil;

/**
 * @author Jimmy Liu
 *
 */
public abstract class BaseTempPaymentServiceImpl<K extends TempPaymentDao<T>, T extends BaseTempPayment > extends BaseServiceImpl implements TempPaymentService<K, T> {
	
	private static final long serialVersionUID = 2177561312787629606L;
	
	protected abstract K getDao();

	public int addBaseTempPayment(T entity) {
		
		Date now = new Date();
		String updateBy = UserUtil.getUserGroup().getGroupNo()+"_"+UserUtil.getUserId();
		entity.setCreatedDate(now);
		entity.setCreatedBy(updateBy);
		entity.setUpdatedDate(now);
		entity.setUpdatedBy(updateBy);
		
		return getDao().insert(entity);
	}

	public int addBaseTempPayments(List<T> entities) {
		Date now = new Date();
		String updateBy = UserUtil.getUserGroup().getGroupNo()+"_"+UserUtil.getUserId();
		for(T t : entities)
		{
			t.setCreatedDate(now);
			t.setCreatedBy(updateBy);
			t.setUpdatedDate(now);
			t.setUpdatedBy(updateBy);
		}
		int updateCount = getDao().insert(entities);
		
		return updateCount;
	}

	public int deleteByTempUploadFilePk(Long deleteByTempUploadFilePk) {
		return getDao().deleteByTempUploadFilePk(deleteByTempUploadFilePk);
	}
	
	public TempUploadFile getSummary(TempUploadFile tempUploadFile){
		return getDao().getSummary(tempUploadFile);
	}
	
	public void summaryPaymentChk(TempUploadFile tempUploadFile)
	{
		throw new NotImplementedException();
	}
	
	public PaginatedList<T> findPaginatedListByTempUploadFilePk(Long pk,
			PaginatedList<T> paginatedList) {
		return getDao().queryForPaginatedListByTempUploadFilePk(pk, paginatedList);
	}
	
	
	public PaginatedList<T> findChkPaginatedListByUploadFilePk(Long pk,
			PaginatedList<T> paginatedList) {
		return getDao().queryChkForPaginatedListByUploadFilePk(pk, paginatedList);
	}
}
